const getsitnav = () => ajax({
  url: 'http://chst.vip:1234/api/getsitenav',
})
getsitnav().then(res => {
  let arr = res.result
  arr = [...arr]

  let html =''
  let mainUl = document.querySelector('#main>ul')
  arr.forEach(item => {
    console.log(item);
    html += `
    <li>
      <a href="${item.navHref}">
        <img src="${item.navImg}">
        <span>&nbsp;${item.navTitle}</span>
      </a>  
    </li>
    `
  });
  mainUl.innerHTML = html

})

// 点击回到顶部
let backTop = document.querySelector("#goTop");
backTop.onclick = function (e) {
  e.preventDefault();
  let distans = document.documentElement.scrollTop;
  let distansControl = setInterval(function () {
    distans -= 10;
    document.documentElement.scrollTop = distans;
    if (distans <= 0) {
      clearInterval(distansControl);
    }
  }, 3);
};